

$(function () {
    $.when(
        vm.init()
      );


});










var vm = new Vue({
    el: '#rrapp',

    data: {


        userallmy:null,
        aPBase: {pBCollectid: []},
        category_type: [],
        operation_state:[],
        progect_type:[],
        fw:[],
        bb:[]


    },
    methods: {

         init:function (event)
         {
             $.get(baseURL + "api/bdatadictionary/select?d_code=operation_state", function (r) {
                 vm.operation_stat = r.returnlist;
             });
             $.get(baseURL + "api/bdatadictionary/select?d_code=category_type", function (r) {
                 vm.category_type = r.returnlist;
             });
             $.get(baseURL + "api/bdatadictionary/select?d_code=progect_type", function (r) {
                 vm.progect_type = r.returnlist;
             });
             $.get(baseURL + "api/bdatadictionary/select?d_code=progect_type", function (r) {
                 vm.progect_type = r.returnlist;
             });
             $.get(baseURL + "api/bdatadictionary/select?d_code=edition_type ", function (r) {
                 vm.bb = r.returnlist;
             });
             $.get(baseURL + "api/bdatadictionary/select?d_code=project_scope ", function (r) {
                 vm.fw = r.returnlist;
             });
             vm.getInfo(GetUrlParam("guid"))

         },
        saveOrUpdate: function (event) {
            var url = vm.aPBase.guid == null ? "bss/apbase/save" : "bss/apbase/update";

            $.ajax({
                type: "POST",
                url: baseURL + url,
                contentType: "application/json",
                data: JSON.stringify(vm.aPBase),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },


        getInfo: function (guid) {
            $.get(baseURL + "bss/apbase/info/" + guid, function (r) {
                vm.aPBase = r.aPBase;
                vm.aPBase.pBCollectid = r.aPBase.pBCollectid.replace(/\"/g, "").replace("[", "").replace("]", "").split(",");
                vm.userallmy = r.userallmy;
                var i = 0;
                var item = new Array();
                for (d in progect_type) {

                    if (progect_type[d].dKey == r.aPBase.pBType) {

                        item[i] = progect_type[d];
                        i++;
                    }
                }

            });
        }
    }
});